<?php
/**
 * 21天减重测评算法
 * Created by PhpStorm.
 * User: liao
 * Date: 2016/12/12
 * Time: 16:41
 */

namespace App\Services\Algo;

use App\Interf\Calculable;
use TestingItemService;
use App\Models\LogHelper;

class MetaWeightAlgo extends BaseTestingAlgo implements Calculable
{
    private $typeFourExpress ;
    public function __construct($tid, $answerStr, $typeFourExpress = null)
    {
        parent::__construct($tid, $answerStr);
        $this->typeFourExpress = $typeFourExpress;
    }

    public function calculate()
    {
        if($this->typeFourExpress){
            $fourTypeResult = $this->fourTypeArray($this->typeFourExpress,$this->answers);
            foreach($fourTypeResult as $v){
                array_push($this->answers,$v);
            }
        }
        return $this->entrance($this->tid, $this->answers);

    }

    /**
     * 将拼装后的答案转换成字符串
     * @return string
     */
    public function resultToStr(){
        return $this->arrToStr($this->answers);
    }




    /**
     * @param $tid
     * @param $answers
     * @return float|null
     */
    protected function entrance($tid,$answers){
        $totalScore =null;
//        foreach ($answers as $answer){
//            $totalScore = $totalScore + $answer['weight'];
//        }
        return $totalScore;
    }



}